<template>
	<view>
		<customizePickerVue :pickerValue.sync="pricePicker" :mask-style="setStyle" :picker-column="setPickerColumn" centerSymbol="至" @bindChange="changePicker"/>
	</view>
</template>

<script>
	import customizePickerVue from '../../../components/customize-picker/customize-picker.vue';

	export default {
		props: {
			start: {
				type: String,
				default: ''
			},
			end: {
				type: String,
				default: ''
			},
			type: Number, // 2 全职金额筛选  3兼职金额筛选
			fullTimeList: {
				type: Array,
				default: () => ([])
			},
			partTimeList: {
				type: Array,
				default: () => ([])
			},
		},
		components: {
			customizePickerVue,
		},
		data() {
			return {
				newShow: false,
        		pricePicker: [0,0],
				pickerColumn: [
					{
						suffix: '元',
						key: 'start',
						list: [],
					},
					{
						suffix: '元',
						key: 'end',
						list: [],
					},
				]
			};
		},
		computed: {
			setPickerColumn(){
				const list = this.type === 2 ? this.fullTimeList : this.partTimeList;
				const arr = this.pickerColumn.map(v => {
					v.list = list.map(v => v.valueNum);
					return v;
				});
				this.reset();
				// console.log(arr);
				return arr;
			},
			/* 小程序不支持两个类名 */
			setStyle(){
				return `background-image: linear-gradient(rgba(255,255,255, 0.95), rgba(255,255,255, 0.6)), linear-gradient(0deg, rgba(255,255,255, 0.95), rgba(255,255,255, 0.6));`;
			},
		},
		watch: {
			start(val){
				console.log(this.start,this.end);
			}
		},
		mounted(){
			// this.setPickerColumn();
			// this.resetTime();
		},
		methods: {
			changeShow(){
				this.$emit('update:show',this.newShow);
				this.$emit('changeShow', 'workingHours');
			},
			reset(){
				this.pricePicker = [0,0];
			},
			changePicker(){
				const priceArr = [];
				const textArr = [];
				this.pricePicker.forEach((v, i) => {
					const str = this.setPickerColumn[i].list[v];
					textArr.push(`${str}元`);
					priceArr.push(str);
				});
				// const sp = Number(priceArr[0]);
				// const ep = Number(priceArr[1]);
				// let tips;
				// if (sp > ep) tips = '最低薪资不可大于最高薪资';
				// if (tips) {
				// 	uni.showToast({
				// 		title: tips,
				// 		icon: 'none',
				// 		mask: true,
				// 	})
				// 	return false;
				// }
				const start = textArr[0];
				const end = textArr[1];
				this.$emit("update:start",start);
				this.$emit("update:end",end);
				this.$emit('endChange',{start,end});
				// this.resetTime();
			},
		}
	}
</script>

<style lang="less" scoped>
</style>
